package sz.szsmk.citizencard.util;

import sz.szsmk.citizencard.DaggerApplication;
import sz.szsmk.citizencard.model.network.bean.request.QuestionReq;
import sz.szsmk.citizencard.model.network.bean.request.ResetPsdReq;
import com.youzan.spiderman.utils.MD5Utils;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/7/23 10:03
 * description:
 */
public class SineUtils {

    public static void setSine(ResetPsdReq resetPsdReq, String access_token,
                               String androidId, String setPsdEtSure, String oldPsd, String refresh_token) {


        String key = "access_token=" + access_token + "&device_id=" + androidId + "&newPassWord=" + setPsdEtSure
                + "&oldPassWord=" + oldPsd + "&key=" + refresh_token;
        String stringMd5 = MD5Utils.getStringMd5(key).toUpperCase();
        resetPsdReq.setSign(stringMd5);
    }

    public static void setSing(QuestionReq questionReq) {

        String androidId = AndroidUtils.getAndroidId(DaggerApplication.getIns());
        String refresh_token = ACache.get(DaggerApplication.getIns()).getAsString("refresh_token");
        String access_token = ACache.get(DaggerApplication.getIns()).getAsString("access_token");
        questionReq.setDevice_id(androidId);
        questionReq.setAccess_token(access_token);
        String key = "access_token=" + access_token + "&device_id=" + androidId + "&key=" + refresh_token;
        String aCase = MD5Utils.getStringMd5(key).toUpperCase();
        questionReq.setSign(aCase);


    }

    public void setDeviceId() {
        AndroidUtils.getAndroidId(DaggerApplication.getIns());
    }


}
